<!-- 学生课程管理-课表安排 -->
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="/css/font.css">
		<link rel="stylesheet" href="/css/xadmin.css">
	</head>

	<body>
		<div class="x-body" id="app">
			<xblock class="layui-form">
				<!-- <button class="layui-btn" onclick="autoCourse()"><i class="layui-icon">&#xe655;</i>自动排课</button> -->
				<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);"
				 title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
				<span class="x-right" style="line-height:40px">共有数据：{{ classCourses.length }} 条</span>
				<input type="hidden" name="classId" th:attr="value=${classId}"/>
			</xblock>
			<table class="layui-table layui-form">
				<thead>
					<tr>
						<th>课程代码</th>
						<th>课程名称</th>
						<th>上课星期</th>
						<th>上课时间</th>
						<th width="80">授课教室</th>
						<th width="80">授课教师</th>
						<!-- <th width="60">自动排课</th> -->
						<th width="60">操作</th>
				</thead>
				<tbody>
					<tr v-for="classCourse in classCourses">
						<td>{{ classCourse.courseNo }}</td>
                        <td>{{ classCourse.courseName }}</td>
                        <td>{{ classCourse.startDay }}</td>
                        <td>{{ classCourse.startTime }}</td>
                        <td>{{ classCourse.roomName }}</td>
                        <td>{{ classCourse.teacherName }}</td>
						<!-- <td>
						  <input type="checkbox"  name="autoCheckbox" :value="classCourse.id" lay-text="开启|关闭" lay-skin="switch"><div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch"><em>开启</em><i></i></div>
						</td> -->
						<td class="td-manage">
							<button class="layui-btn layui-btn layui-btn-sm" v-on:click="open_editCourseTime(classCourse.courseName,classCourse.id)"><i class="layui-icon">&#xe642;</i>编辑</button>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<script type="text/javascript" src="/js/jquery.min.js"></script>
        <script type="text/javascript" src="/js/xadmin.js"></script>
        <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/js/vue.min.js"></script>
        <script type="text/javascript" src="/js/jquery.form.js"></script>
		<script>
			var vm = new Vue({
	            el : '#app',
	            data : {
	                // 当前班级的课程列表
	                classCourses: "",
	                // 当前班级id
	                classId: ""
	            },
	            created : function() {
	                this.classId = $("input[name='classId']").val();
	                // 获取教师课程列表
	                this.listClassCourse(this.classId);
	            },
	            methods : {
	            	listClassCourse : function(classId) {
	                    var vm = this;
	                    $.ajax({
	                        url : "/sys/student/course/listClassCourse",
	                        data: {
	                        	classId: classId
	                        },
	                        type : "get",
	                        success : function(result) {
	                            if (result.state) {
	                            	vm.classCourses = result.data;
	                            } else {
	                                layui.use(['layer'], function(){
	                                    var layer = layui.layer
	                                    layer.msg(""+result.msg, {icon: 5});
	                                });
	                            }
	                        }
	                    });
	                }
	            }
	        });

			// 打开课表编辑页面
			function open_editCourseTime(courseName, courseId) {
				x_admin_show('编辑课表['+ courseName +']','/sys/student/course/toCourseTimeEdit?courseId=' + courseId, 600, 300);
			}
			
			
			
			
			/* // 自动排课
            function autoCourse() {
                var stuCourseIds =[]; 
                $("input[name='autoCheckbox']:checked").each(function() {
                	stuCourseIds.push($(this).val()); 
                });
                if (stuCourseIds.length > 0) {
                    $.ajax({
                        url : "/sys/student/course/autoStuCourse",
                        data: {
                        	stuCourseIds: stuCourseIds
                        },
                        type : "get",
                        success : function(result) {
                            if (result.state) {
                                layer.msg("自动排课成功", {icon: 1},function(){
                                    // 刷新页面
                                    location.reload();
                                });
                            } else {
                                layui.use(['layer'], function(){
                                    var layer = layui.layer
                                    layer.msg(""+result.msg, {icon: 5});
                                });
                            }
                        }
                    });
                }
            } */
			
			// 编辑后回调
			function updateEditData() {
				vm.listClassCourse(vm.classId);
			}
		</script>
	</body>

</html>
